﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NHibernate;
using Bizbase.Repository.Nhibernate;
using System.Collections;

namespace Bizbase.Repository
{
    public class SqlQuery : ISqlQuery
    {
        private ISessionFactory _sessionFactory;
        private ISession _session;

        public SqlQuery(IDatabase database)
        {
            _sessionFactory = database.SessionFactory;
            _session = _sessionFactory.OpenSession();
        }

        public void UpdateOrDelete(string sql)
        {

        }

        public void Select(string sql)
        {
            ISQLQuery query = _session.CreateSQLQuery(sql);
            IList result = query.List();
        }

        public void Dispose()
        {
            if (_session != null)
            {
                _session.Flush();
                _session.Close();
                _session.Dispose();
                _session = null;
            }
        }
    }
}
